Skip to content

Support to extract and compare image SBOM #458

Merged
magerstam merged 12 commits intomainfrom
inspect-sbom
Mar 10, 2026
Merged

Support to extract and compare image SBOM #458
magerstam merged 12 commits intomainfrom
inspect-sbom

Conversation

@magerstam
Copy link
Copy Markdown
Contributor

@magerstam magerstam commented Mar 2, 2026

Merge Checklist

All boxes should be checked before merging the PR

  • The changes in the PR have been built and tested
  • Documentation has been updated to reflect the changes (or no doc update needed)
  • Ready to merge

Description

  • The os-image-composer supports generation of SBOM (Software Bill of Material) using included packages during the image generation process. The SBOM SPDX json file is stored under the root partition in /usr/share/sbom.
  • The inspect command has been expanded to optionally support extraction of the embedded SPDX manifest from an image using the command os-image-composer inspect --extract-sbom <filename>. The output filename is optional, if not provided, the filename as it appears on the filesystem will be used
  • The compare command has been extracted to support comparison of SBOM content by using the following mode; --mode=spdx where two SPDX JSON files can be provided for comparison highlighting all the differences between the two SBOMs.
  • The RAW filesystem now supports reading ext3 and ext4 data from a partition

Any Newly Introduced Dependencies

How Has This Been Tested?

Added unit-test to cover inspect and compare commands

@magerstam magerstam marked this pull request as ready for review March 2, 2026 21:30
@magerstam magerstam requested a review from a team as a code owner March 2, 2026 21:30
Copilot AI review requested due to automatic review settings March 2, 2026 21:30
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Expands os-image-composer inspection and comparison capabilities to work with embedded SBOMs (SPDX JSON) inside generated images, including an SPDX-to-SPDX comparison mode and raw-partition SBOM extraction support (ext2/3/4 via debugfs).

Changes:

  • Add SBOM discovery/parsing utilities (canonical SPDX hashing + package diffing) and include SBOM metadata in image inspection summaries/diffs.
  • Extend CLI: inspect --extract-sbom [out] to extract embedded SPDX and compare --mode=spdx to compare two SPDX JSON files directly.
  • Enable raw ext2/3/4 reads for SBOM extraction using debugfs (and allowlist debugfs in the shell command map), plus unit tests.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
internal/utils/shell/shell.go Allowlists debugfs so raw ext* extraction can invoke it via the shell utility.
internal/image/imageinspect/sbom.go Implements SBOM inspection, canonical SPDX hashing, and SPDX file comparison/diff helpers.
internal/image/imageinspect/sbom_test.go Adds tests for canonical hashing stability and SPDX compare behavior.
internal/image/imageinspect/fs_raw.go Adds raw-partition SBOM discovery + ext2/3/4 reading via debugfs.
internal/image/imageinspect/imageinspect.go Adds SBOMSummary to ImageSummary and inspector options to enable SBOM inspection.
internal/image/imageinspect/compare.go Adds SBOM diffing and summary reporting (SBOMChanged).
internal/image/imageinspect/renderer_text.go Renders SBOM info in inspect output and SBOM diffs in compare text output; adds SPDX-compare text renderer.
internal/image/imageinspect/helpers_test.go Updates verity-related tests for the renamed VeritySummary type.
internal/image/imageinspect/compare_test.go Updates verity comparison tests for VeritySummary.
cmd/os-image-composer/inspect_cmd.go Adds --extract-sbom flag handling and writes extracted SBOM to file/dir.
cmd/os-image-composer/inspect_cmd_test.go Adds unit tests for SBOM extraction flag semantics and output writing.
cmd/os-image-composer/compare_cmd.go Adds --mode=spdx to compare two SPDX JSON files (text/json output).
cmd/os-image-composer/compare_cmd_test.go Adds tests covering SPDX compare mode without inspecting disk images.

Comment thread internal/image/imageinspect/sbom.go Outdated
Comment thread internal/image/imageinspect/fs_raw.go
Comment thread internal/image/imageinspect/sbom.go
Comment thread internal/image/imageinspect/sbom.go
…o help with debugging SBOM inspection issues.
@magerstam magerstam requested a review from a team as a code owner March 2, 2026 21:55
Comment thread cmd/os-image-composer/inspect_cmd.go Outdated
Copy link
Copy Markdown
Contributor

@arodage arodage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One comment to address.Otherwise LGTM

Copy link
Copy Markdown
Contributor

@stevenhoenisch stevenhoenisch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the .md file in the commit set. (I didn't look at the .go files or other code files.)

@magerstam magerstam merged commit f9c6d22 into main Mar 10, 2026
34 checks passed
@magerstam magerstam deleted the inspect-sbom branch March 10, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants